import sys
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *

class SliderDemo(QWidget):
    def __init__(self):
        super().__init__()
        self.initUI()

    def initUI(self):
        self.setWindowTitle("滑块空间演示")
        self.resize(300,400)

        layout=QVBoxLayout()
        self.label=QLabel("你好啊")
        self.label.setAlignment(Qt.AlignCenter)

        layout.addWidget(self.label)
        self.slider=QSlider(Qt.Horizontal)
        #设置最小值和最大值
        self.slider.setMinimum(12)
        self.slider.setMaximum(48)
        #步长
        self.slider.setSingleStep(3)
        #设置当前值
        self.slider.setValue(18)
        #设置刻度的位置，刻度在下方
        self.slider.setTickInterval(QSlider.TicksBelow)
        #设置刻度的间隔
        self.slider.setTickInterval(6)
        layout.addWidget(self.slider)
        self.slider.valueChanged.connect(self.valueChanged)
        self.setLayout(layout)

    def valueChanged(self):
        print("当前的值:",self.slider.value())
        size=self.slider.value()
        self.label.setFont(QFont("Arial",size))


if __name__ == '__main__':
    app=QApplication(sys.argv)
    myc=SliderDemo()
    myc.show()
    sys.exit(app.exec_())
